package view;

import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import controller.ActionAdmin;

@SuppressWarnings("serial")
public final class Menu extends JMenuBar{
	JMenuBar menu = null;
	JMenu alert;
	JMenu  statistiche;
	JMenu  database;
	static JMenuItem utentiDb;
	static JMenuItem eventiDb;
	JMenuItem utentiSt;
	JMenuItem eventiSt;
	ActionListener action = new ActionAdmin();
	public static boolean flagAlert = false;
	public static boolean flagEvent = false;

	public Menu() {
		menu = this;
		adminMenu();
	}

	public void adminMenu(){
		alert = new JMenu("Alert");
		alert.setMnemonic(KeyEvent.VK_A);

		statistiche = new JMenu("Statistiche");
		statistiche.setMnemonic(KeyEvent.VK_S);

		database = new JMenu("Database");
		database.setMnemonic(KeyEvent.VK_D);

		utentiDb = new JMenuItem("Alert Utente");
		utentiDb.setName("utnDb");
		utentiDb.addActionListener(action);

		eventiDb = new JMenuItem("Visualizza Eventi");
		eventiDb.setName("evnDb");
		eventiDb.addActionListener(action);

		utentiSt = new JMenuItem("Stat Utenti");
		utentiSt.setName("utnSt");
		utentiSt.addActionListener(action);

		eventiSt = new JMenuItem("Stat Eventi");
		eventiSt.setName("evnSt");
		eventiSt.addActionListener(action);

		statistiche.add(eventiSt);
		statistiche.add(utentiSt);

		database.add(eventiDb);

		alert.add(utentiDb);

		menu.add(alert);
		menu.add(database);
		menu.add(statistiche);
		menu.setVisible(true);
	}

	public static void pauseMenu() {
		eventiDb.setEnabled(false);
		utentiDb.setEnabled(false);
	}

	public static void restartMenu() {
		eventiDb.setEnabled(true);
		utentiDb.setEnabled(true);
	}
}
